package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldTrainReceiveDto;
import com.cleaningcloud.cld.domain.vo.CldTrainReceiveVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldTrainReceive;
import com.cleaningcloud.cld.service.ICldTrainReceiveService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 受训人信息Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-26
 */
@RestController
@RequestMapping("/receive")
public class CldTrainReceiveController extends BaseController
{
    @Autowired
    private ICldTrainReceiveService cldTrainReceiveService;

    /**
     * 查询受训人信息列表
     */
//    @RequiresPermissions("cld:receive:list")
    @GetMapping("/list")
    public TableDataInfo list(CldTrainReceiveDto cldTrainReceive)
    {
        startPage();
        List<CldTrainReceiveVo> list = cldTrainReceiveService.selectCldTrainReceiveList(cldTrainReceive);
        return getDataTable(list);
    }


    /**
     * 获取受训人信息详细信息
     */
//    @RequiresPermissions("cld:receive:query")
    @GetMapping(value = "/{trainReceiveId}")
    public AjaxResult getInfo(@PathVariable("trainReceiveId") Long trainReceiveId)
    {
        return success(cldTrainReceiveService.selectCldTrainReceiveByTrainReceiveId(trainReceiveId));
    }

    /**
     * 新增受训人信息
     */
//    @RequiresPermissions("cld:receive:add")
    @Log(title = "受训人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldTrainReceive cldTrainReceive)
    {
        return toAjax(cldTrainReceiveService.insertCldTrainReceive(cldTrainReceive));
    }

    /**
     * 修改受训人信息
     */
//    @RequiresPermissions("cld:receive:edit")
    @Log(title = "受训人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldTrainReceive cldTrainReceive)
    {
        return toAjax(cldTrainReceiveService.updateCldTrainReceive(cldTrainReceive));
    }

    /**
     * 删除受训人信息
     */
//    @RequiresPermissions("cld:receive:remove")
    @Log(title = "受训人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trainReceiveIds}")
    public AjaxResult remove(@PathVariable Long[] trainReceiveIds)
    {
        return toAjax(cldTrainReceiveService.deleteCldTrainReceiveByTrainReceiveIds(trainReceiveIds));
    }
}
